package com.lyy.common.utils;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import org.apache.commons.lang3.ObjectUtils;

/**
 * @author 俞伟
 * @version 1.0
 * @date 2020/8/26
 * @description com.tongsheng.common.utils
 */
public class AssertUtils {

    public static void notNull(Object data, String errorMsg) {
        if (ObjectUtils.isEmpty(data)) {
            throw new IllegalArgumentException(errorMsg);
        }
    }

    public static void notNull(String errorMsg, Object... data) {
        for (Object obj : data) {
            notNull(obj, errorMsg);
        }
    }

    public static void notNull(String[] errorMsg, Object[] data) {
        for (int i = 0; i < errorMsg.length; i++) {
            notNull(errorMsg[i], data[i]);
        }
    }

    public static void isTrue(boolean expression, String errorMsg) {
        if (expression) {
            throw new IllegalArgumentException(errorMsg);
        }
    }

    public static void isFalse(boolean expression, String errorMsg) {
        isTrue(!expression, errorMsg);
    }

    public static void error(String errorMsg) {
        throw new IllegalArgumentException(errorMsg);
    }
}
